home *** CD-ROM | disk | FTP | other *** search
- DEFINT A-Z
-
- '------------------------------- Define Types ---------------------------
-
- TYPE RegType 'Type statement for CALL INTERRUPT
- ax AS INTEGER 'ax register
- bx AS INTEGER 'bx register
- cx AS INTEGER 'cx register
- dx AS INTEGER 'dx register
- bp AS INTEGER
- si AS INTEGER
- di AS INTEGER
- flags AS INTEGER
- ds AS INTEGER
- es AS INTEGER
- END TYPE
-
- '--------------------------- Declare Procedures -------------------------
-
- DECLARE FUNCTION GetPath$ (Drive$)
- DECLARE FUNCTION GetDrive$ ()
- DECLARE FUNCTION ParseCommandLine$ ()
- DECLARE SUB DIR (Path$, DirArray() AS STRING, FA%)
- DECLARE SUB DisplayFiles ()
- DECLARE SUB DisplayFreeSpace ()
- DECLARE SUB DisplayVolume ()
- DECLARE SUB GetFiles ()
- DECLARE SUB Initialize ()
- DECLARE SUB INTERRUPT (IntNo%, InReg AS RegType, OutReg AS RegType)
- DECLARE SUB InterruptX (IntNo%, InReg AS RegType, OutReg AS RegType)
- DECLARE SUB KillWindow (XStart%, YStart%, DeltaX%, DeltaY%, WindowMemory$)
- DECLARE SUB MakeWindow (XStart%, YStart%, DeltaX%, DeltaY%, ForegroundColor%, BackgroundColor%, Border%, WindowMemory$)
- DECLARE SUB PopOff ()
- DECLARE SUB Popup ()
- DECLARE SUB ScrollUp (AL%, BH%, CH%, CL%, DH%, DL%)
- DECLARE SUB ScrollDown (AL%, BH%, CH%, CL%, DH%, DL%)
- DECLARE SUB WindowControl ()
-
- '------------------------------ Dimensions-------------------------------
-
- DIM Info(256) AS STRING
- DIM regs AS RegType, sb AS STRING * 64
-
- '- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
-
- COMMON SHARED Info() AS STRING, WinBuff AS STRING * 4000, OldY, MaxInfo, Total
- COMMON SHARED Drive AS STRING, Path AS STRING
- COMMON SHARED b, f, x, y, dx, dy
- COMMON SHARED Top, Bottom
-
- '************************************************************************
- '** Main Program **
- '************************************************************************
-
- Initialize
- Popup
- DisplayVolume
- DisplayFreeSpace
- GetFiles
- DisplayFiles
- WindowControl
- PopOff
-
- END
-
- '************************************************************************
- '************************************************************************
-
- SUB DisplayFiles
- '------------------------------------------------------------------------
- ' procedure DisplayFiles displays the first part of the list of files
- ' in the window.
- '------------------------------------------------------------------------
-
- LOCATE y + (dy - 4), x + 2
- IF MaxInfo > 0 THEN
- LOCATE y + 2, x + (dx - 13)
- PRINT USING "###"; MaxInfo; :
- PRINT " File(s)";
- SWAP f, b
- COLOR b, f
- ScrollUp 0, 112, y + 4, x + 1, y + (dy - 5), x + (dx - 2)
- FOR u = Top TO Bottom
- LOCATE y + u + 3, x + 3
- PRINT Info(u);
- NEXT u
- ELSE
- LOCATE y + 8, x + (dx - 34)
- PRINT "File Not Found."
- SWAP b, f
- END IF
-
- END SUB
-
- SUB DisplayFreeSpace
- '------------------------------------------------------------------------
- ' procedure DisplayFreeSpace calculates the free disk space on the
- ' specified drive and displays it in the window.
- '------------------------------------------------------------------------
-
- DIM regs AS RegType
-
- regs.ax = &H3600
- regs.dx = ASC(Drive$) - 64
- INTERRUPT &H21, regs, regs
- BytesAvail& = regs.ax * regs.cx
- BytesAvail& = regs.bx * BytesAvail&
- LOCATE y + dy - 3, x + 2
- PRINT USING "#########"; BytesAvail&; :
- PRINT " bytes available on drive "; Drive$; ":"
-
- END SUB
-
- SUB DisplayVolume
- '------------------------------------------------------------------------
- ' procedure DisplayVolume gets the volume name from the specified drive
- ' and displays it.
- '------------------------------------------------------------------------
-
- DIR Drive$ + ":\*.*", Info(), &H8
-
- LOCATE y + 2, x + 1
- PRINT " Volume Name: ";
- IF INSTR(LEFT$(Info(1), 12), " ") > 1 THEN
- PRINT LEFT$(Info(1), 12)
- ELSE
- PRINT "<Unlabeled>";
- END IF
-
- END SUB
-
- SUB GetFiles
- '------------------------------------------------------------------------
- ' procedure GetFiles gets the files matching the current search string
- ' into the array Info().
- '------------------------------------------------------------------------
-
- Total = 0
-
- DIR Path$, Info(), &H10
-
- StopFlag = 0
- WHILE INSTR(Info(Total + 1), " ") > 1 AND StopFlag < 2
- Total = Total + 1
- IF INSTR(Info(Total), " ") > 1 THEN
- ELSE
- Total = Total - 1
- StopFlag = StopFlag + 1
- END IF
- WEND
-
- MaxInfo = Total
- IF MaxInfo <= dy - 8 THEN
- Bottom = MaxInfo
- ELSE
- Bottom = dy - 8
- END IF
-
- END SUB
-
- SUB Initialize
- '------------------------------------------------------------------------
- ' procedure Initialize sets up default variables.
- '------------------------------------------------------------------------
-
- b = 7
- f = 0
- x = 16
- y = 3
- dx = 49
- dy = 20
-
- Path$ = ParseCommandLine$
- OldY = CSRLIN - 1
- IF OldY = 0 THEN OldY = 1
-
- LOCATE , , 0
-
- END SUB
-
- FUNCTION ParseCommandLine$
- '------------------------------------------------------------------------
- ' procedure ParseCommandLine returns a search string using the command
- ' line arguments passed from DOS. If no command line arguments were
- ' passed, it builds a path from the default DOS drive and path.
- '------------------------------------------------------------------------
-
- ParsePath$ = COMMAND$
- FileSpec$ = "*.*"
- IF RIGHT$(ParsePath$, 2) = ".." THEN ParsePath$ = ParsePath$ + "\*.*"
- IF RIGHT$(ParsePath$, 1) = "." AND LEN(ParsePath$) = 1 THEN ParsePath$ = ""
- IF RIGHT$(ParsePath$, 1) = "." AND (LEFT$(RIGHT$(ParsePath$, 2), 1) = ":" OR LEFT$(RIGHT$(ParsePath$, 2), 1) = "\") THEN ParsePath$ = LEFT$(ParsePath$, LEN(ParsePath$) - 1) + "*.*"
-
- IF ParsePath$ = "" THEN
- Drive$ = GetDrive$
- ParsePath$ = Drive$ + ":\" + GetPath$(Drive$)
- IF p$ = "" THEN FileSpec$ = "*.*"
- ELSEIF LEN(ParsePath$) = 3 AND INSTR(ParsePath$, ":") = 2 THEN
- ParsePath$ = ParsePath$
- Drive$ = LEFT$(ParsePath$, 1)
- ELSEIF LEN(ParsePath$) = 2 AND RIGHT$(ParsePath$, 1) = ":" THEN
- Drive$ = LEFT$(ParsePath$, 1)
- ParsePath$ = Drive$ + ":\" + GetPath$(Drive$)
- IF GetPath$(Drive$) = "" THEN FileSpec$ = "*.*"
- ELSE
- IF INSTR(ParsePath$, ":") <> 2 THEN
- Drive$ = GetDrive$
- ELSE
- Drive$ = LEFT$(ParsePath$, 1)
- ParsePath$ = RIGHT$(ParsePath$, LEN(ParsePath$) - 2)
- END IF
- IF LEFT$(ParsePath$, 1) = "\" THEN
- ParsePath$ = Drive$ + ":" + ParsePath$
- ELSE
-
- IF GetPath$(Drive$) = "" THEN FileSpec$ = "*.*"
- IF GetPath$(Drive$) = "" THEN
- ParsePath$ = Drive$ + ":" + GetPath$(Drive$) + "\" + ParsePath$
- ELSE
- ParsePath$ = Drive$ + ":\" + GetPath$(Drive$) + "\" + ParsePath$
- END IF
- END IF
- IF INSTR(ParsePath$, ".") > 0 THEN
- FileSpec$ = ""
- FOR s = LEN(ParsePath$) TO 1 STEP -1
- IF MID$(ParsePath$, s, 1) = "\" THEN EXIT FOR ELSE FileSpec$ = MID$(ParsePath$, s, 1) + FileSpec$
- NEXT s
- ParsePath$ = LEFT$(ParsePath$, s)
- END IF
- END IF
-
- IF RIGHT$(ParsePath$, 1) <> "\" AND LEFT$(FileSpec$, 1) <> "\" THEN FileSpec$ = "\" + FileSpec$
- ParseCommandLine$ = ParsePath$ + FileSpec$
-
- END FUNCTION
-
- SUB PopOff
- '------------------------------------------------------------------------
- ' procedure PopOff restores the screen and re-locates the cursor where
- ' it was upon entry to the program.
- '------------------------------------------------------------------------
-
- KillWindow x, y, dx, dy, WinBuff$
- LOCATE OldY, 1, 1
-
- END SUB
-
- SUB Popup
- '------------------------------------------------------------------------
- ' procedure DoWindow puts a window on the screen and details it after
- ' saving the contents of the screen behind it.
- '------------------------------------------------------------------------
-
- WinText$ = "[ Directory of " + Path$ + " ]"
-
-
- MakeWindow x, y, dx, dy, b, f, 2, WinBuff$
- LOCATE y, x + (dx - (LEN(WinText$))) \ 2
- COLOR f, b
- PRINT WinText$
- COLOR b, f
-
- Top = 1
- COLOR b, f
- LOCATE y + 1, x + (dx - 15)
- PRINT "│"
- LOCATE y + 2, x + (dx - 15)
- PRINT "│"
- LOCATE y + 3, x + 1
- PRINT STRING$(dx - 16, "─");
- PRINT "┴";
- PRINT STRING$(13, "─");
- LOCATE y + dy - 4, x + 1
- PRINT STRING$(dx - 10, "─");
- PRINT "┬───────";
- LOCATE y + dy - 3, x + (dx - 9)
- PRINT "│"
- LOCATE y + dy - 2, x + (dx - 9)
- PRINT "│"
-
- END SUB
-
- SUB WindowControl
- '------------------------------------------------------------------------
- ' procedure WindowControl manages the files in the window and updates
- ' the window.
- '------------------------------------------------------------------------
-
- WHILE Key$ <> CHR$(27)
- Key$ = UCASE$(INKEY$)
- IF Total = 0 THEN
- COLOR f, b
- LOCATE y + dy - 3, x + dx - 3
- PRINT CHR$(25);
- LOCATE y + dy - 3, x + dx - 4
- PRINT CHR$(24);
- COLOR b, f
- END IF
- IF Bottom > MaxInfo AND Total > 0 THEN
- COLOR f, b
- LOCATE y + dy - 3, x + dx - 3
- PRINT CHR$(25);
- COLOR 15, 0
- LOCATE y + dy - 3, x + dx - 4
- PRINT CHR$(24);
- COLOR b, f
- ELSEIF Top = 1 AND Total > 0 THEN
- COLOR 15, 0
- LOCATE y + dy - 3, x + dx - 3
- PRINT CHR$(25);
- COLOR f, b
- LOCATE y + dy - 3, x + dx - 4
- PRINT CHR$(24);
- COLOR b, f
- ELSE
- IF Total > 0 THEN
- LOCATE y + dy - 3, x + dx - 4
- COLOR 15, 0
- PRINT CHR$(24); CHR$(25)
- COLOR b, f
- END IF
- END IF
-
- DEF SEG = 0
-
- LOCATE y + dy - 1, x + dx - 11
-
- IF PEEK(&H417) AND 64 THEN
- PRINT "CAP";
- ELSE
- PRINT "═══";
- END IF
-
- LOCATE y + dy - 1, x + dx - 16
-
- IF PEEK(&H417) AND 32 THEN
- PRINT "NUM";
- ELSE
- PRINT "═══";
- END IF
-
- LOCATE y + dy - 1, x + dx - 6
-
- IF PEEK(&H417) AND 16 THEN
- PRINT "SCR";
- ELSE
- PRINT "═══";
- END IF
-
- DEF SEG
-
- IF LEN(Key$) > 1 THEN
-
- IF ASC(RIGHT$(Key$, 1)) = 72 AND Top > 1 THEN
- ScrollDown 1, 112, y + 4, x + 3, y + (dy - 5), x + (dx - 4)
- Bottom = Bottom - 1
- Top = Top - 1
- LOCATE y + 4, x + 3
- PRINT Info(Top);
- END IF
-
- IF ASC(RIGHT$(Key$, 1)) = 80 AND Bottom < MaxInfo AND MaxInfo > (dy - y) - 5 THEN
- ScrollUp 1, 112, y + 4, x + 3, y + (dy - 5), x + (dx - 4)
- Top = Top + 1
- Bottom = Bottom + 1
- LOCATE y + (dy - 5), x + 3
- PRINT Info(Bottom);
- END IF
- END IF
- WEND
-
- END SUB
-
-